package com.augn.controller;

import com.augn.entity.Cart;
import com.augn.entity.Result;
import com.augn.service.ICartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author augn
 * @since 2022-09-22
 */
@RestController
@RequestMapping("/cart")
public class CartController {

    @Autowired
    private ICartService service;

    @PostMapping("/insertOne")
    public Result<?> insertOneCart(@RequestBody Cart cart) {
        return service.insertOneCart(cart);
    }

    @DeleteMapping("/deleteOne/{id}")
    public Result<?> deleteOneCart(@PathVariable Integer id) {
        return service.deleteOneCart(id);
    }

    @PutMapping("/updateOne")
    public Result<?> updateOneCart(@RequestBody Cart cart) {
        return service.updateOneCart(cart);
    }

    @GetMapping("/getPart/{id}")
    public Result<?> getPartCart(@PathVariable Integer id){
        return service.getPartCart(id);
    }
}
